import theImageViewer from './index2.vue';
import { h, render } from 'vue';


const renderImageViewer = () => {
    const container = document.createElement('div');
    container.id = 'theImageViewer';
    // 创建 虚拟dom
    const imageViewerVNode = h(theImageViewer);
    // 将虚拟dom渲染到 container dom 上
    render(imageViewerVNode, container);
    // 最后将 container 追加到 body 上
    document.body.appendChild(container);
    return imageViewerVNode;
}
let imageInstance;
const imageViewer = (info) => {
    if (imageInstance) {
        const imageVue = imageInstance.component;
        imageVue?.exposed?.open?.(info);
    } else {
        imageInstance = renderImageViewer();
        imageViewer(info);
    }
}

export default imageViewer;